import 'dart:convert';
import 'package:cloud_medicine/components/util.dart';
import 'package:cloud_medicine/http/HttpUtil.dart';
import 'package:dio/dio.dart';

// 获取评论列表
Future getComment_api(String url, dynamic data) async {
  String token = await getToken();
  Response res = await HttpUtil.get(
    url,
    parameters: data,
    headers: {'Authorization': token},
  );
  return jsonDecode(res.data);
}

// 增加评论
Future addComment_api(String url, dynamic data) async {
  String token = await getToken();
  Response res = await HttpUtil.request(
    url,
    method: HttpUtil.POST,
    parameters: data,
    headers: {'Authorization': token},
  );
  return jsonDecode(res.data);
}

// 评论点赞
Future likeComment_api(String url, dynamic data) async {
  String token = await getToken();
  Response res = await HttpUtil.request(
    url,
    method: HttpUtil.PUT,
    parameters: data,
    headers: {'Authorization': token},
  );
  return jsonDecode(res.data);
}